package com.seu.vcampus.view.library;

import com.seu.vcampus.client.VCampusClient;
import com.seu.vcampus.util.UIStyleUtil;
import com.seu.vcampus.vo.User;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * 图书馆管理窗口
 * 采用按钮跳转模式的现代化图书馆管理界面
 * 
 * @author 虚拟校园开发团队
 * @since 2.2.0
 */
public class LibraryManagementFrame extends JFrame {
    private VCampusClient client;
    private User currentUser;
    
    public LibraryManagementFrame(VCampusClient client, User user) {
        super("图书馆管理 - " + user.getUsername());
        this.client = client;
        this.currentUser = user;
        
        initializeComponents();
        setupLayout();
        setupEventHandlers();
        
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setSize(1200, 800);
        setLocationRelativeTo(null);
        setLocation(getX() + 50, getY() + 50); // 偏移显示
    }
    
    /**
     * 初始化组件
     */
    private void initializeComponents() {
        // 设置全局样式
        UIStyleUtil.setupGlobalStyle();
        
        // 使用新的按钮式主界面
        LibraryMainPanel mainPanel = new LibraryMainPanel(client, currentUser);
        add(mainPanel);
    }
    
    /**
     * 设置布局
     */
    private void setupLayout() {
        // 已经在initializeComponents中完成
    }
    
    /**
     * 设置事件处理器
     */
    private void setupEventHandlers() {
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                // 窗口关闭时通知主界面
                dispose();
            }
        });
    }
}